<template>
    <Table :columns="columns10" :data="data9"></Table>
</template>
<script>
import expandRow from './table-expand.vue'
export default {
    components: { expandRow },
    data () {
        return {
            columns10: [
                {
                    type: 'expand',
                    width: 50,
                    render: (h, params) => {
                        return h(expandRow, {
                            props: {
                                row: params.row
                            }
                        })
                    }
                },
                {
                    title: 'Name',
                    key: 'name'
                },
                {
                    title: 'Age',
                    key: 'age'
                },
                {
                    title: 'Address',
                    key: 'address'
                },
                {
                    title: '操作',
                    key: 'action',
                    width: 190,
                    align: 'center',
                    render: (h, params) => {
                        return h('div', [
                            h(
                                'Button',
                                {
                                    props: {
                                        type: 'primary',
                                        size: 'large'
                                    },
                                    style: {
                                        marginRight: '5px'
                                    },
                                    on: {
                                        click: () => {
                                            this.editData(params.row.id)
                                        }
                                    }
                                },
                                '编辑'
                            ),
                            h(
                                'Button',
                                {
                                    props: {
                                        type: 'error',
                                        size: 'large'
                                    },
                                    on: {
                                        click: () => {
                                            this.remove(params.index, params.row.id)
                                        }
                                    }
                                },
                                '删除'
                            )
                        ])
                    }
                }
            ],
            data9: [
                {
                    name: 'John Brown',
                    age: 18,
                    address: 'New York No. 1 Lake Park',
                    job: 'Data engineer',
                    interest: 'badminton',
                    birthday: '1991-05-14',
                    book: 'Steve Jobs',
                    movie: 'The Prestige',
                    music: 'I Cry'
                },
                {
                    name: 'Jim Green',
                    age: 25,
                    address: 'London No. 1 Lake Park',
                    job: 'Data Scientist',
                    interest: 'volleyball',
                    birthday: '1989-03-18',
                    book: 'My Struggle',
                    movie: 'Roman Holiday',
                    music: 'My Heart Will Go On'
                },
                {
                    _expanded:true,
                    name: 'Joe Black',
                    age: 30,
                    address: 'Sydney No. 1 Lake Park',
                    job: 'Data Product Manager',
                    interest: 'tennis',
                    birthday: '1992-01-31',
                    book: 'Win',
                    movie: 'Jobs',
                    music: 'Don’t Cry'
                },
                {
                    _expanded:true,
                    name: 'Jon Snow',
                    age: 26,
                    address: 'Ottawa No. 2 Lake Park',
                    job: 'Data Analyst',
                    interest: 'snooker',
                    birthday: '1988-7-25',
                    book: 'A Dream in Red Mansions',
                    movie: 'A Chinese Ghost Story',
                    music: 'actor'
                }
            ]
        }
    }
}
</script>
